package com.spring.demo.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.spring.demo.core.entity.CustomerInfo;
import com.spring.demo.core.entity.Order;
import com.spring.demo.core.service.ICacheService;
import com.spring.demo.core.service.IOrderServer;

/**
 * just hello world!
 * 
 * @author sean
 * 
 */
@Controller
public class HelloController {

	@Autowired
	private ICacheService cacheService;
	@Autowired
	private IOrderServer orderServer;

	@RequestMapping(value = "/hello", produces = MediaType.TEXT_HTML_VALUE)
	@ResponseBody
	public String hello(HttpServletRequest request) {
		cacheService.getUserMap();
		return "Spring mvc hello world!";
	}

	@RequestMapping("/event")
	@ResponseBody
	public String event() {
		CustomerInfo customerInfo = new CustomerInfo(1l);
		Order order = new Order(1l, "电脑配件", customerInfo);
		orderServer.postponed(order);
		return "event async";
	}
}
